#pragma once
#include"HastTable.h"


namespace ns_unordered_map_set {
	template<class K>
	class unordered_set {
	public:
		struct SetKeyOfT {
			const K& operator()(const K& key) {
				return key;
			}
		};

		typedef typename OpenHash::HashTable<K, K, SetKeyOfT>::iterator iterator;
		
		iterator begin() {
			return _ht.begin();
		}

		iterator end() {
			return _ht.end();
		}

		
		pair<iterator, bool> insert(const K& key) {
			return _ht.Insert(key);
		}

		void erase(const K& key)
		{
			_ht.Erase(key);
		}

		iterator find(const K& key)
		{
			return _ht.Find(key);
		}

	private:
		OpenHash::HashTable<K, K, SetKeyOfT> _ht;
	};

	void test_unordered_set() {
		unordered_set<int> us;
		us.insert(200);
		us.insert(1);
		us.insert(2);
		us.insert(33);
		us.insert(50);
		us.insert(60);
		us.insert(243);
		us.insert(6);

		unordered_set<int>::iterator it = us.begin();
		while (it != us.end()) {
			cout << *it << " ";
			++it;
		}
	}
} 
